<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%--http://localhost:8080/admin/test/ssm.html--%>
    <base href="http://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">
    <script type="text/javascript" src="jquery/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#btn3").click(function () {
                    // 准备要发送的 JSON 数据
                var student = {
                    "id": "999",
                    "name": "tom"/*,
                    "address": {
                        "province": "ShanDong",
                        "city": "heze",
                        "street": "hello"
                    }*//*,
                    "subject": [
                        {
                            "subjectName":"schoolONe",
                            "subjectScore":500
                        },{
                            "subjectName":"22222",
                            "subjectScore":222
                        }
                    ],
                    "map": {
                        "yingyu": 100,
                        "shuxue": 80,
                        "wuli": 90
                    }*/
                };
                    // 将 JSON 对象转换为 JSON 字符串
                var arrayStr3 = JSON.stringify(student);
                    // 发送 Ajax 请求
                $.ajax({
                    "url":"send/array3.json",
                    "type":"post",
                    "data":arrayStr3,                      //请求参数
                    "contentType":"application/json;charset=UTF-8",
                    "dataType":"json",
                    "success":function (response) {     //response是响应体数据
                        console.log(response)
                    },
                    "error":function (response) {
                        console.log(response)
                    }
                })
            })


            $("#btn2").click(function () {
                    // 准备要发送的数组
                var array = [5,8,12];
                    // 将 JSON 数组转换成 JSON 字符串
                var arrayStr = JSON.stringify(array);

                $.ajax({
                    "url":"send/array2.html",
                    "type":"post",
                    "data":arrayStr,                      //请求参数
                    "contentType":"application/json;charset=UTF-8",
                    "dataType":"text",
                    "success":function (response) {     //response是响应体数据
                        console.log(response)
                    },
                    "error":function (response) {
                        console.log(response)
                    }
                })
            })
        })
    </script>

</head>
<body>
    <a href="test/ssm.html">ssm环境测试</a>
    <button id="btn1">send [3,4,6] One</button>
    <button id="btn2">send Two</button>
    <button id="btn3">send Three Complex</button>
    <br>
<a href="admin/to/login/page.html">登录</a>
</body>
</html>
